<?php
class Lichhoc extends Vnf_Db_Table {
    protected $_name;
    protected $_primary = 'lichhoc_id';

    function __construct() {
        $this->_name = DB_PREFIX . "lichhoc";
        parent::__construct();
    }
	
    public function getColumns() {
        $results = array('lichhoc_id', 'lichhoc_date', 'lichhoc_place', 'lichhoc_num', 'lichhoc_khoahoc_id');
        return $results;
    }

    public function getPrimaryKey() {
        $pk = $this->_primary;
        if (is_array($pk)) {
            if (count($pk) > 0)
                return $pk[1]; // array[1] contain column name of primary key
        }
        return $this->_primary;
    }

    public function getByKH($idKH){
    	$select = Zend_Db_Table_Abstract::select();
        $select->setIntegrityCheck(false);
        $select->from(array('a' => $this->_name));
        $select->where('lichhoc_khoahoc_id = ?', $idKH);
        $data = $this->fetchAll($select);
        if ($data) {
            return $data->toArray();
        }
        return $data;
    }
	public function getById($id){
    	$select = Zend_Db_Table_Abstract::select();
        $select->setIntegrityCheck(false);
        $select->from(array('a' => $this->_name));
        $select->where('lichhoc_id = ?', $id);
        $data = $this->fetchAll($select);
        if ($data) {
            return $data->toArray();
        }
        return $data;
    }
	public function numIncrease($id){
     	settype($id,'int');
     //$objLH= new lichhoc();
    	$sql = "update ".$this->_name." set lichhoc_num=lichhoc_num+1 where lichhoc_id=".$id;
        $this->_db->query($sql);
       //$array=array('lichhoc_num'=>1);
		//mysql_query("update webtm_sanpham set SoLanXem=SoLanXem+1 where idSP=".$idSP);
	//	$this->update($array, "airline_id = ?", $id);
        
    }
}
?>
